/*
 Data loader for spreadsheet under GNU general public liscence
 */

/**
 *
 * @author lanchana
 * @DataLoader to the spreadsheet
 * @email:lanch.gunawardhana@gmail.com
 */
package DBHandler;

import MsgViewer.MessageBox;
import java.sql.Connection;
import java.sql.DriverManager;

public class DBConnector {
    public DBConnector(){

    }


private static Connection con;
public static boolean  setConnector(DBConnectionData dbData)
{
    try
    {
         Class.forName("com.mysql.jdbc.Driver");//establish connection using mysql jdbc driver
         String connectionString="jdbc:mysql://"+dbData.getIpaddress()+"/"+dbData.getDbname();
         con=DriverManager.getConnection(connectionString,dbData.getUsername(),dbData.getPassword());
         System.out.println(con.isValid(10));
         return true;
    }
    catch(Exception ex){
       new MessageBox().displayMsg("ERROR","Something wrong with your fields.Please enter the correct data and try again");
        return false;
    }
}

public static Connection getConnectionInstance()
{
    return con;
}



}